/**
 * Validates the event country.
 * 
 * @author Michael Serajnik
 */

package at.fhj.itm10.ticketmaster.validators;

import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.FacesValidator;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;

@FacesValidator(value = "EventCountryValidator")
public class EventCountryValidator implements Validator {

	public void validate(FacesContext context, UIComponent component, Object value)
			throws ValidatorException {
		
		String eventCountry = (String) value;
		
		if(eventCountry.length() == 0 || eventCountry.length() > 20) {
			throw new ValidatorException(new FacesMessage("Bitte gib einen g\u00FCltige Staat mit maximal 20 Zeichen an."));
		}
		
	}

}
